分类
联系方式
  1. 新浪微博
  2. E-mail

Windows Chocolate 包管理器

介绍

用惯了 macOS 下的 Brew,切换到 Windows 还是习惯找一个包管理器。Chocolate 是 Windows 下著名的包管理器。

安装

用管理员身份打开 Powershell,首先需要确认 Get-ExecutionPolicy 没有被限制。官方建议使用 Bypass 来跳过或者考虑安全的话使用 AllSigned。

查看方式,运行:

Get-ExecutionPolicy

我这里返回的是 RemoteSigned,官方说如果返回 Restricted,执行:

Set-ExecutionPolicy Bypass -Scope Process

之后再执行:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

升级

安装的时候我发现自己已经安装过了,软件提示我升级,调用:

choco upgrade chocolatey

结果报错:

Chocolatey detected you are not running from an elevated command shell

参考文章《Chocolatey trying to install in non-elevated environment》

  • Type cmd on windows search
  • Right click on CMD result, and click run as administrator.

原来用管理员运行 CMD 才叫 elevated command,用管理员运行 PowerShell 就不是。

默认安装路径

0.9.8.24 以后默认安装在 C:\ProgramData\chocolatey 下。

以前是安装在 C:\Chocolatey 下。

修改默认安装路径

参考文章《How do I set Chocolatey to install applications onto another drive?》

官方提供的修改方式需要授权,每个月 8 刀。

网友提供的方式是使用符号链接,连接到目标位置:

mklink /J "C:/ProgramData/Chocolatey" "D:/Chocolatey"

网络资源

安装手册